package com.wsq.servicewindow;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.AnimationDrawable;
import android.media.Image;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;

/**
 * Date:2021/7/5
 * Time:16:31
 * author:wushengqi
 */
public class GazeViewDialog extends AlertDialog {

    private Context mContext;

    protected GazeViewDialog(@NonNull Context context) {
        super(context, R.style.exit_cast_activity_style);
        this.mContext = context;

    }

//    protected GazeViewDialog(@NonNull Context context, int themeResId) {
//        super(context, themeResId);
//        this.mContext = context;
//    }
// Unable to start activity ComponentInfo{}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
//    protected GazeViewDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
//        super(context, cancelable, cancelListener);
//        this.mContext = context;
//    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        getWindow().setGravity(Gravity.TOP);
//        Rect rect = getWindow().getWindowManager().getCurrentWindowMetrics().getBounds();
        layoutParams.width = getWindow().getWindowManager().getDefaultDisplay().getWidth();//WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = getWindow().getWindowManager().getDefaultDisplay().getHeight();//WindowManager.LayoutParams.MATCH_PARENT;
        getWindow().setAttributes(layoutParams);
        View view = LayoutInflater.from(mContext).inflate(R.layout.see_screen_dialog, null, false);
        ImageView imageView = view.findViewById(R.id.img_gaze_mm);
        imageView.setImageResource(R.drawable.anim_gaze_viewer);
        AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable();
        animationDrawable.start();
        setContentView(view);
    }

    @Override
    public void show() {

        super.show();


    }
}
